//
//  CZPictureCell.swift
//  SinaBlog
//
//  Created by 李超 on 16/3/26.
//  Copyright © 2016年 lichao. All rights reserved.
//

import UIKit
import SDWebImage

class CZPictureCell: UICollectionViewCell {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.brownColor()
        prepareUI()
        
    }
    //图片的url
    var imageUrl:NSURL?{
        
        didSet{
            
            if let url = imageUrl{
                
                iconView.sd_setImageWithURL(url, placeholderImage: nil, options:SDWebImageOptions.RetryFailed)
            }
            
        }
        
    }
    
    func prepareUI(){
        //添加控件
        contentView.addSubview(iconView)
        //添加约束
        iconView.snp_makeConstraints { (make) -> Void in
            
            make.edges.equalTo(contentView)
            
        }
        
        iconView.contentMode = UIViewContentMode.ScaleAspectFill
        iconView.clipsToBounds = true
        
        contentView.snp_makeConstraints { (make) -> Void in
            
            make.edges.equalTo(self)
        }
        
        
    }

    
    private lazy var iconView:UIImageView =  UIImageView()
    
}
